#include <iostream>
#include <string>

using namespace std;

struct BinaryTree {
    BinaryTree(char ch)
        : _val(ch),
          _left(nullptr),
          _right(nullptr)
    {}
    char _val;
    BinaryTree* _left;
    BinaryTree* _right;
};

BinaryTree* BuildBinaryTree(const string& s, int& i) {
    if (s[i] == '#')
    {
        ++i;
        return nullptr;
    } 
        BinaryTree* node = new BinaryTree(s[i++]);
        node->_left = BuildBinaryTree(s, i);
        node->_right = BuildBinaryTree(s, i);
    return node;
}

void BinaryInOrder(BinaryTree* root)
{
    if (!root)
        return;
    BinaryInOrder(root->_left);
    cout << root->_val << " ";
    BinaryInOrder(root->_right);
    return;
}

int main() {
    string str;
    cin >> str;
    int i = 0;
    BinaryInOrder(BuildBinaryTree(str,i));
    return 0;
}
// 64 位输出请用 printf("%lld")